//
// Created by denglibin on 2019/6/27 0027.
//
#include <iostream>
#include <vector>
using namespace std;

class A{
private:
    char c; //内存对齐 会多分配7个字节
    char x[8];
    char *d;
    char *e;
};

void study_1(){
    unsigned int a = 10;
    int b = -1;
    int d = (int) a;
    unsigned c = (unsigned int) b;
    cout << d << "," << c << endl; //10,4294967295
    if(b < a){
        cout << "right" << endl;
    }else{
        cout << "bad" << endl; //结果 bad
    }
    cout << sizeof(A) << endl; //内存对齐 64位指针8个字节
    char arr[16];
    cout << sizeof(arr) << endl; //16
    char * ar = arr;
    cout << sizeof(ar) << endl; //8 指针8个字节
    cout << sizeof(std::size_t) << endl; // 8
}

namespace A_{
    struct X{int x;};
    void f(int){cout << "A::f" << endl;}
}
namespace B{
    void f(A_::X x){
        cout << "B::f" << endl;
        f(x); //B::f
    }
}
struct alignas(8) S{}; //alignas 以多少个字节对齐 如果写0 会忽略掉以默认对齐
void study_2(){
    int a = 1;
    int b = 2;
    if(a == 1 and b == 2){ // and 关键字 同 &&
        cout << "and right" << endl;
    }
    b and_eq a; // b &= a (b = b & a);
    cout << b << endl;
    auto c = a bitand b; // &
    auto d = a bitor b; // |
    cout << sizeof(bool) << endl;

    auto e = true;
    *(char *)(&e) = -1;
    cout << e << endl;//255
    char16_t cc = 'e';

    auto f = 1.0f;
    decltype(f) t = 2;
    typeof(t) z = 3 ;

}
int main0() {

    study_2();
    return 0;
}

